package com.ruoyi.system.service.impl;

import java.util.Collection;
import java.util.Date;
import java.util.List;

import cn.hutool.core.convert.Convert;
import cn.hutool.core.date.DateUtil;
import cn.hutool.core.lang.UUID;
import cn.hutool.core.util.RandomUtil;
import com.alibaba.fastjson2.util.UUIDUtils;
import com.ruoyi.common.constant.CacheConstants;
import com.ruoyi.common.core.domain.model.LoginUser;
import com.ruoyi.common.core.redis.RedisCache;
import com.ruoyi.common.utils.SecurityUtils;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;
import com.ruoyi.system.mapper.MesFactoryMapper;
import com.ruoyi.system.domain.MesFactory;
import com.ruoyi.system.service.IMesFactoryService;

/**
 * editFactoryService业务层处理
 * 
 * @author ruoyi
 * @date 2022-07-14
 */
@Service
public class MesFactoryServiceImpl implements IMesFactoryService 
{
    @Autowired
    private MesFactoryMapper mesFactoryMapper;
    @Autowired
    private RedisCache redisCache;

    /**
     * 查询editFactory
     * 
     * @param id editFactory主键
     * @return editFactory
     */
    @Override
    public MesFactory selectMesFactoryById(Long id)
    {
        return mesFactoryMapper.selectMesFactoryById(id);
    }

    /**
     * 查询editFactory列表
     * 
     * @param mesFactory editFactory
     * @return editFactory
     */
    @Override
    public List<MesFactory> selectMesFactoryList(MesFactory mesFactory)
    {
        return mesFactoryMapper.selectMesFactoryList(mesFactory);
    }

    /**
     * 新增editFactory
     * 
     * @param mesFactory editFactory
     * @return 结果
     */
    @Override
    public int insertMesFactory(MesFactory mesFactory)
    {
        String username = SecurityUtils.getUsername();

        mesFactory.setId(RandomUtil.randomInt());
        mesFactory.setCreatetime(Convert.toDate(DateUtil.now()) );
        mesFactory.setSite("factory:"+ mesFactoryMapper.findSiteNum());
        mesFactory.setIsuse("0");
        mesFactory.setCreateuser(username);
        return mesFactoryMapper.insertMesFactory(mesFactory);
    }

    /**
     * 修改editFactory
     * 
     * @param mesFactory editFactory
     * @return 结果
     */
    @Override
    public int updateMesFactory(MesFactory mesFactory)
    {
        return mesFactoryMapper.updateMesFactory(mesFactory);
    }

    /**
     * 批量删除editFactory
     * 
     * @param ids 需要删除的editFactory主键
     * @return 结果
     */
    @Override
    public int deleteMesFactoryByIds(Long[] ids)
    {
        return mesFactoryMapper.deleteMesFactoryByIds(ids);
    }

    /**
     * 删除editFactory信息
     * 
     * @param id editFactory主键
     * @return 结果
     */
    @Override
    public int deleteMesFactoryById(Long id)
    {
        return mesFactoryMapper.deleteMesFactoryById(id);
    }
}
